package test13;

import java.sql.*;

public class Test2 {

    public static void main(String[] args) {

        Connection connection=null;
        Statement statement=null;
        ResultSet resultSet=null;
        String sql="insert into t_students(id,stu_no,real_name) values(1,01,'a')";


        try {
            //加载驱动程序
            Class.forName("com.mysql.jdbc.Driver");

            try {
                connection = DriverManager.getConnection(
                        "jdbc:myaql://localhost:3306/java_2017?serverTimezoen=UTC",
                        "root",
                        "sctu123456"
                );

                statement = connection.createStatement();

                resultSet =statement.executeQuery(sql);

                while (resultSet.next()){

                    System.out.println(resultSet.getString(1));
                    System.out.println(resultSet.getString(2));
                    System.out.println(resultSet.getString(3));
                    System.out.println(resultSet.getString(4));
                    System.out.println(resultSet.getString(5));
                    System.out.println(resultSet.getString(6));
                }
            } catch (SQLException e) {
                e.printStackTrace();
            }
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }finally {


            try {
                statement.close();
                connection.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }
}
